﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_TransferClients : System.Web.UI.Page
{
    BankDataDataContext db = new BankDataDataContext();

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void GridViewOperators_SelectedIndexChanged(object sender, EventArgs e)
    {
        foreach (GridViewRow row in GridViewOperatorClients.Rows)
        {
            CheckBox isSelectedCompany = (CheckBox)row.FindControl("companyIsSelected");
            if (isSelectedCompany.Checked)
            {
                int profileId = Convert.ToInt32(GridViewOperatorClients.DataKeys[row.RowIndex]["ProfileId"].ToString());
                var profiles = from profile in db.UserProfiles where profile.ProfileId == profileId select profile;
                profiles.First().OperatotId = Convert.ToInt32(GridViewOperators.DataKeys[GridViewOperators.SelectedIndex]["OperatorId"].ToString());
                db.SubmitChanges();
            }
        }
        Response.Redirect("~/Admin/TransferClients.aspx");
    }
}